#include <iostream>
#include <cxxabi.h>

// 一个递归终止条件的函数
template<typename T>
void print(T first) {
    std::cout << first <<std::endl;
}

// 递归调用，打印第一个参数，然后打印剩余的参数
template<typename T, typename... Args>
void print(T first, Args... args) {
    std::cout << first << " ";
    print(args...);
}

template<typename...args>
class test;

template<typename T>
class test<T>{

public:
    void print(){
     // 获取经过修饰的类型名
    const char* typeName = typeid(*this).name();

    // 使用 __cxa_demangle 进行反修饰
    int status;
    char* readableName = abi::__cxa_demangle(typeName, 0, 0, &status);

    if (status == 0) {
        std::cout << "Readable name: " << readableName << std::endl;
        std::cout << "Unreadable name: " << typeName << std::endl;
        std::cout << "Unreadable name: " << *(typeName+7) << std::endl;

        std::free(readableName); // 注意释放内存
    } else {
        std::cerr << "Failed to demangle name" << std::endl;
    }
    }// print()

};


int main() {
    print(1, 2.5, "Hello", 'c');

    test<int> obj_test;
    obj_test.print();

    return 0;
}
